//
//  BaseInfoCell.m
//  LuCaiZhu
//
//  Created by 邓龙 on 2019/5/8.
//

#import "BaseInfoCell.h"

@interface BaseInfoCell()
@property (weak, nonatomic) IBOutlet UILabel *name;
@property (weak, nonatomic) IBOutlet UILabel *detail;

@end

@implementation BaseInfoCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setDataAction:(BaseInfoModel *)model type:(NSString *)type index:(NSInteger)index {
    index = index - 1;
    NSArray *list = nil;
    NSLog(@"%@", type);
    if ([type isEqualToString:@"A"]) {
        list = @[@{@"name": @"基金管理人", @"value": [self padNull:model.Vendor]},
                 @{@"name": @"基金托管人", @"value": [self padNull:model.ManagedBank]},
                 @{@"name": @"基金类型", @"value": [self padNull:model.ProductTypeLevel2]},
                 @{@"name": @"产品期限", @"value": [self padNull:model.ProductPeriodShow]},
                 @{@"name": @"认/申购起点（万元）", @"value": [self padNull:model.MinimumAmount]},
                 @{@"name": @"递进金额（万元）", @"value": [self padNull:model.ProgressiveAmount]},
                 @{@"name": @"募集期限", @"value": [self padNull:model.Recruitmentshow]},
                 @{@"name": @"产品成立日", @"value": [self padNull:model.PurchaseOpenDay]},
                 @{@"name": @"业绩比较基准", @"value": [self padNull:model.ExpectedRate]},
                 @{@"name": @"资金用途", @"value": [self padNull:model.Usage]}];
    }
    else if ([type isEqualToString:@"B"]) {
        list = @[@{@"name": @"基金管理人", @"value": [self padNull:model.Vendor]},
                 @{@"name": @"基金托管人", @"value": [self padNull:model.ManagedBank]},
                 @{@"name": @"基金类型", @"value": [self padNull:model.ProductTypeLevel2]},
                 @{@"name": @"认购起点 （万元）", @"value": [self padNull:model.MinimumAmount]},
                 @{@"name": @"递进金额（万元）", @"value": [self padNull:model.ProgressiveAmount]},
                 @{@"name": @"募集期限", @"value": [self padNull:model.Recruitmentshow]},
                 @{@"name": @"产品成立日", @"value": [self padNull:model.PurchaseOpenDay]},
                 @{@"name": @"产品期限", @"value": [self padNull:model.ProductPeriodShow]},
                 @{@"name": @"期间分配", @"value": [self padNull:model.AllocationMethod]},
                 @{@"name": @"业绩比较基准 ", @"value": [self padNull:model.ExpectedRate]}];
    }
    else if ([type isEqualToString:@"C"]) {
        list = @[@{@"name": @"基金管理人", @"value": [self padNull:model.Vendor]},
                 @{@"name": @"基金托管人", @"value": [self padNull:model.ManagedBank]},
                 @{@"name": @"基金类型", @"value": [self padNull:model.ProductTypeLevel2]},
                 @{@"name": @"认缴出资起点（万元）", @"value": [self padNull:model.MinimumAmount]},
                 @{@"name": @"募集期限", @"value": [self padNull:model.Recruitmentshow]},
                 @{@"name": @"首次交割日", @"value": [self padNull:model.PurchaseOpenDay]},
                 @{@"name": @"产品期限", @"value": [self padNull:model.ProductPeriodShow]},
                 @{@"name": @"投资策略", @"value": [self padNull:model.InvestScope]}];
    }
    else {
        list = @[@{@"name": @"基金管理人", @"value": [self padNull:model.Vendor]},
                 @{@"name": @"基金托管人", @"value": [self padNull:model.ManagedBank]},
                 @{@"name": @"基金类型", @"value": [self padNull:model.ProductTypeLevel2]},
                 @{@"name": @"认/申购起点（万元）", @"value": [self padNull:model.MinimumAmount]},
                 @{@"name": @"申/赎开放日", @"value": [self padNull:model.PurchaseOpenDay]},
                 @{@"name": @"认/申购费%", @"value": [self padNull:model.BookingFee]},
                 @{@"name": @"封闭期是否可赎回", @"value": [self padNull:model.ClosePeriodRedeem]},
                 @{@"name": @"封闭期赎回费率%", @"value": [NSString stringWithFormat:@"%@", [self padNull:model.ClosePeriodRedeemRate]]},
                 @{@"name": @"封闭期后赎回费率%", @"value": [NSString stringWithFormat:@"%@", [self padNull:model.RedeemFee]]},
                 @{@"name": @"投资范围", @"value": [self padNull:model.InvestScope]}];
    }
    
    _name.text = list[index][@"name"];
    _detail.text = list[index][@"value"];
}

- (NSString *)padNull:(NSString *)str {
    return str?str:@"";
}

@end
